dhcpv6: add t1 and t2 transmission
authorNicolas BESNARD <[email protected]>
Fri, 25 Oct 2024 15:24:34 +0000 (17:24 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 3 Nov 2025 15:14:46 +0000 (16:14 +0100)
Problem: there was no way to get access to the t1 and t2 that the
dhcpv6 server sends to the client

Solution: add the timing in the Prefix and Address sent to the
environment.

Signed-off-by: Nicolas BESNARD <[email protected]>
Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcp6c/pull/106
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/script.c

index 4b06c692dd606af716061c46437c477359829679..0f4be344d6046d477aacf729d51f1d74e6620208 100644 (file)
@@ -171,7 +171,7 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en
        size_t buf_len = strlen(name);
        const struct odhcp6c_entry *e = data;
        // Worst case: ENTRY_PREFIX with iaid != 1 and exclusion
-       const size_t max_entry_len = (INET6_ADDRSTRLEN-1 + 5 + 22 + 15 + 10 +
+       const size_t max_entry_len = (INET6_ADDRSTRLEN-1 + 5 + 44 + 15 + 10 +
                                      INET6_ADDRSTRLEN-1 + 11 + 1);
        char *buf = realloc(NULL, buf_len + 2 + (len / sizeof(*e)) * max_entry_len);
 
@@ -208,7 +208,7 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en
                                snprintf(&buf[buf_len], 23, ",%u,%u", e[i].valid, e[i].priority);
                                buf_len += strlen(&buf[buf_len]);
                        } else {
-                               snprintf(&buf[buf_len], 23, ",%u,%u", e[i].preferred, e[i].valid);
+                               snprintf(&buf[buf_len], 45, ",%u,%u,%u,%u", e[i].preferred, e[i].valid, e[i].t1, e[i].t2);
                                buf_len += strlen(&buf[buf_len]);
                        }